﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace xiaolanshu
{
    public partial class 个人推荐 : Form
    {
        public 个人推荐()
        {
            InitializeComponent();
        }

        private void 个人推荐_Load(object sender, EventArgs e)
        {
            用户信息.telephone = "13817403561";
            BackgroundImageLayout = ImageLayout.Stretch;
            label1.Text = "根据您的肤色与肤质，\r\n\r\n我们为您推荐以下产品：";
            SqlConnection conn = SQLTools.conn;
            SqlCommand cmd = new SqlCommand("color_recom", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@telephone", SqlDbType.Char, 11).Value = 用户信息.telephone;
            cmd.Parameters.Add("@color", SqlDbType.Int);
            cmd.Parameters["@color"].Direction = ParameterDirection.Output;
            /*string sql = @"select 肤色 from 用户 where 手机号='"+用户信息.telephone+"'";*/
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            用户信息.skin_color = (int)cmd.Parameters["@color"].Value;
            Data.getLipData();
            switch(用户信息.skin_color/20)
            {
                case 0: 
                    lipBox1.box_data = Data.lipstick_data.Rows[0];
                    break;
                case 1:
                    lipBox1.box_data = Data.lipstick_data.Rows[1];
                    break;
                default:
                    lipBox1.box_data = Data.lipstick_data.Rows[2];
                    break;
            }
            lipBox1.reload();
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void likeit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
